<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>计算器</title>
    <script type="text/javascript">
        var calculate = function (i) {
            var number_1 = document.getElementById("number_1").value;
            var number_2 = document.getElementById("number_2").value;
            var number_3 = 0;

            if (isNaN(number_1) || isNaN(number_2)) {
                alert("请输入正确的数字");
                return;
            }
            switch (i) {
                case 1:
                    number_3 = (number_1 - 0) + (number_2 - 0);
                    break;
                case 2:
                    number_3 = (number_1 - 0) - (number_2 - 0);
                    break;
                case 3:
                    number_3 = (number_1 - 0) * (number_2 - 0);
                    break;
                case 4:
                    number_3 = (number_1 - 0) / (number_2 - 0);
                    break;
            }
            document.getElementById("result").value = number_3;
        }
    </script>
</head>
<body>
<label for="number_1">第一个数字：</label><input type="text" id="number_1">
<br>
<label for="number_2">第二个数字：</label><input type="text" id="number_2">
<br>
<button onclick="calculate(1)">+</button>
<button onclick="calculate(2)">-</button>
<button onclick="calculate(3)">*</button>
<button onclick="calculate(4)">/</button>
<br>
<label for="result">计算结果：</label><input type="text" id="result">
<br>

</body>
</html>